import { IHttpResponse } from "@/utils/http/IHttpResponse";
import http from "@/utils/http/http";
import { OpenBoxResponse, SkinListResponse } from "@/types/box";

interface IList {
    type_id?: number,
    rarity_id?: number,
    keyword?: string,
    page?: number,
    page_size?: number;
    box_type?: 0 | 1 | 2 | 3;
}

interface IId {
    box_id: any
}

interface IOpen {
    box_id: any,
    num: number
}

interface IBoxSkin {
    box_id: any,
    page_size: number,
    sort?: string,
    order?: string
}

interface IBoxSkin2 {
    room_id: any,
	box_id: any,
    page_size: number,
    sort?: string,
    order?: string
}

export default class BoxService {
    static async openRecord(params: IId): Promise<IHttpResponse> {
        return http.get('/api/box/openRecord', { params: { ...params } })
    }

    static async boxSkin(params: IBoxSkin) {
        return http.get<SkinListResponse>('/api/box/skin/list', { params: { ...params } })
    }
	
	static async battleBoxSkin(params: IBoxSkin2) {
		return http.get('/api/battle/room/box/skins', { params: { ...params } })
	}


    static async boxsSkins(ids: number[]) {
        return http.post("/api/boxs/skins", {
            box_ids: ids
        });
    }

    static async list(params: IList): Promise<IHttpResponse> {
        return http.get('/api/box/list', {
            params: { ...params }
        })
    }

    static async id(params: IId): Promise<IHttpResponse> {
        return http.get('/api/box/details', { params: { ...params } })
    }

    static async open(params: IOpen) {
        return http.post<OpenBoxResponse>('/api/box/unpack', { ...params })
    }

    static async allType(params = {}): Promise<IHttpResponse> {
        return http.get('/api/box/boxType/all', {
            params
        })
    }

    static async unpackRechargeWelfareBox(data) {
        return http.post('/api/rechargeWelfareBox/unpack', data)
    }
}
